package cn.ac.cintcm.prespring.cluster.name;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

import org.apache.solr.core.Config;

public class Dictionary {
	
	private static  String zyUrl = Config.getInstanceDir()+ "data/originalData/PRES_ZY.txt";
	private static  String gxUrl = Config.getInstanceDir()+ "data/originalData/PRES_GX.txt";
		
	public static Set<String> wordDict=new HashSet<String>();
	
	public static Set<String> getWordDict()  throws Exception{
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				new FileInputStream(zyUrl), "UTF8"));
		String line = "";
		while ((line = reader.readLine()) != null) {
			String[] s = line.split("    ");
			if (s.length == 2) {				
				String word= s[1];
				wordDict.add(word);
			}
		}
		reader = new BufferedReader(new InputStreamReader(
				new FileInputStream(gxUrl), "UTF8"));
		while ((line = reader.readLine()) != null) {
			String[] s = line.split("    ");
			if (s.length == 2) {				
				String word= s[1];
				wordDict.add(word);
			}
		}
		reader.close();
		return wordDict;
	}

	public static void setWordDict(Set<String> wordDict) {
		Dictionary.wordDict = wordDict;
	}
}
